package com.zzgc.modules.service.impl;

import com.zzgc.common.dao.StaticCityVisualizationDao;
import com.zzgc.common.entity.StaticCityVisualization;
import com.zzgc.modules.service.StaticCityVisualizationService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (StaticCityVisualization)表服务实现类
 *
 * @author makejava
 * @since 2023-05-19 10:16:07
 */
@Service("staticCityVisualizationService")
public class StaticCityVisualizationServiceImpl implements StaticCityVisualizationService {
    @Resource
    private StaticCityVisualizationDao staticCityVisualizationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public StaticCityVisualization queryById(Long id) {
        return this.staticCityVisualizationDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param staticCityVisualization 筛选条件
     * @return 查询结果
     */
    @Override
    public List<StaticCityVisualization> queryByPage(StaticCityVisualization staticCityVisualization) {
        //long total = this.staticCityVisualizationDao.count(staticCityVisualization);
        return this.staticCityVisualizationDao.queryAllByLimit(staticCityVisualization);
    }

    /**
     * 根据年份和筛查次数统计市级信息
     *
     * @return 实例对象
     */
    @Override
    public List<StaticCityVisualization> queryCountSum() {
        return this.staticCityVisualizationDao.queryCountSum();
    }

    /**
     * 新增数据
     *
     * @param staticCityVisualization 实例对象
     * @return 实例对象
     */
    @Override
    public StaticCityVisualization insert(StaticCityVisualization staticCityVisualization) {
        this.staticCityVisualizationDao.insert(staticCityVisualization);
        return staticCityVisualization;
    }

    /**
     * 修改数据
     *
     * @param staticCityVisualization 实例对象
     * @return 实例对象
     */
    @Override
    public StaticCityVisualization update(StaticCityVisualization staticCityVisualization) {
        this.staticCityVisualizationDao.update(staticCityVisualization);
        return this.queryById(staticCityVisualization.getId());
    }

    @Override
    public int restoreUnhealthy(Long id) {
        return this.staticCityVisualizationDao.restoreUnhealthy(id);
    }

    @Override
    public int restoreMyopiaRate(Long id) {
        return this.staticCityVisualizationDao.restoreMyopiaRate(id);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.staticCityVisualizationDao.deleteById(id) > 0;
    }
}
